<!doctype html><html xmlns="http://www.w3.org/1999/xhtml" id="html">
    <head>
        <title></title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <base href="<?= base_url(1); ?>" />
        <link type="text/css" href="css/main.css?v=<?= $config['version'] ?>" rel="stylesheet" />
        <script type="text/javascript" src="<?= $config['res_url'] ?>/js/jquery.min.js?ver=<?= $config['version'] ?>"></script>
        <script>
        
        function getstrateList()
    	{
        	var area = $('#src_area').val();
        	//alert(' area = '+area);
    		var areaList = <?=json_encode($areastratelist)?>;
    		//alert(modList);
    		var strOption = '';
    	    for(var one in areaList[area])
    	    {
        	    strOption +='<tr><td><input type="checkbox" name="row[tableenum][]" '+
        	    			' value="'+one+'"></td>'+
                			'<td><?= translate('ACTIVITY_GROUPSTATEGY_MODULENAME') ?>:'+areaList[area][one]['tabledes']+
                    		'&nbsp;&nbsp;<?= translate('ACTIVITY_GROUPSTATEGY_STRATEGYNAME') ?>:'+
                    		areaList[area][one]['strategyname']+'</td></tr>';
    	    }
    	    if(''==strOption)
    	    {
        	    strOption = ' activity is empty ';
    	    }
    	    //alert(strOption);
    	    $('#add').html(strOption);
    	    $('#desarea').show();
    	    $('#srcmysel').show();
    	}

        $(function() {
            $("#srcselAll").click(function() {
                //alert('srcselAll');
                if ($(this).attr("checked")) {
                    $("input[name*='row[tableenum]']").each(function() {
                        $(this).attr("checked", true);
                    });
                } else {
                    $("input[name*='row[tableenum]']").each(function() {
                        $(this).attr("checked", false);
                    });
                }
            });
            //得到选中的值，ajax操作使用
            $("#test").click(function() {
                var text="";
                $("input[name=items]").each(function() {
                    if ($(this).attr("checked")) {
                        text += ","+$(this).val();
                    }
                });
                 alert(text);
            });

            $("#desselAll").click(function() {
                //alert('srcselAll');
                if ($(this).attr("checked")) {
                    $("input[name*='row[desarea]']").each(function() {
                        $(this).attr("checked", true);
                    });
                } else {
                    $("input[name*='row[desarea]']").each(function() {
                        $(this).attr("checked", false);
                    });
                }
            });
            
        });
                
    	    	
        </script>
    </head>
    <body>
        <?php include(VIEWPATH . 'common/main_header.php'); ?>
        
        <?php
        	//print_r($arealist); 
        ?>
        
        <form action="" method="POST" id="rowForm">
            <table id="tb" width="100%" border="0" cellspacing="1" cellpadding="0" class="tablegrid tableedit">
            	<tr><td>&nbsp;</td><td>&nbsp;</td></tr>

            	<tr><td><?= translate('ACTIVITY_STRATEGY_SRCAREAID') ?>:</td>
	                <td>
	                  <select name="row[srcarea]" id = "src_area" onChange="getstrateList()">
	                  	<option value="-1"><?= translate('SELECT_AREA') ?></option>
	                  	<?php foreach ($arealist as $key=>$value) { ?>
	                    <option value="<?=$key ?>"><?=$key.'-'.$value['name'] ?></option>
	                    <?php } ?>
	                  </select>
	                 </td>
                 </tr>
                
                <div id = 'srcmysel' style="display:none">
                <tr><td><?= translate('SELECT_ALL') ?>:</td>
				<td><input type="checkbox" name="srcselAll" id="srcselAll">
				</td></tr>
                </div>
                
                <table id = 'add' width = '100%'>
                </table>

            	<tr><td>&nbsp;</td><td>&nbsp;</td></tr>   
            	
                <div id = 'desarea' style='display:none'>
                
                <tr><td><?= translate('SELECT_ALL') ?>:</td>
                <td><input type="checkbox" name="desselAll" id="desselAll">
                </td></tr>
                
                <tr><td><?= translate('ACTIVITY_STRATEGY_DESAREAID') ?>:</td>
	                <td>
	                <?php 
	                $i = 0;
	                foreach ($arealist as $key=>$value) { 
	                	if(0 == $i%5) echo "<br>";
	                ?>
	                  <input type="checkbox" name="row[desarea][]"  value="<?=$key ?>" />&nbsp;
	                  <?=$key ?>-<?=$value['name'] ?> &nbsp;&nbsp;
	                <?php 
	                	++$i;
	                } 
	                ?>
	                 </td>
                 </tr>    
                 </div>
                   
                <tr><td><input type="submit" value="<?= translate('SUBMIT') ?>" id="submit"/> </td>
                <td><input type="reset" value="<?= translate('RESET') ?>" id="reset"/></td></tr>
                
            </table>
        </form>
        
    </body>
</html>